import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        level: '第一周', //活动周数
        timer: '', //定时器
        allTime: 0, //总共用时
        itemNum: 1,
        answerId: []
    },
    mutations: {
        remberTime(state) {
            state.timer = setInterval(() => {
                state.allTime++;
            }, 1000)
        },
        add_itemNum(state) {
            state.itemNum++
        },
        remberItemAnswer(state, id) {
            state.answerId.push(id)
        }
    },
    actions: {
        //记录时间
        remberTime(context) {
            context.commit('remberTime');
        },
        //记录第几道题目
        add_itemNum(context) {
            context.commit('add_itemNum');
        },
        //记录用户选择的答案
        remberItemAnswer(context, id) {
            context.commit('remberItemAnswer', id)
        }
    },
    modules: {}
})